<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>外边距</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            text-align: center;
            font-size: 20px;
            line-height: 300px;
            color: white;
        }

        .top {
            background-color: pink;
            margin: 10px;
        }

        .bottom {
            background-color: blue;
            margin: 10px;
        }
    </style>
</head>

<body>
    <div class="top">1</div>
    <div class="bottom">2</div>
</body>

</html>